<?php
/**
 * 订单请求
 *
 * @category 
 * @package 
 * @author chenping<chenping@shopex.cn>
 * @version $Id: Z
 */
class ome_event_trigger_shop_order
{
    /**
     * 淘宝全链路
     *
     * @return void
     * @author 
     **/
    public function order_message_produce($orderIds,$status=array())
    {
        if (!defined('MESSAGE_PRODUCE') || !MESSAGE_PRODUCE)  return;

        $orderModel = app::get('ome')->model('orders');
        $orderList = $orderModel->getList('order_id,order_bn,source,shop_id',array('order_id'=>$orderIds));

        if (!$orderList) return ;

        $orderObjectModel = app::get('ome')->model('order_objects');
        $rows = $orderObjectModel->getList('order_id,oid',array('order_id'=>$orderIds));
        $orderObjectList = array();

        foreach ($rows as $row) {
            $orderObjectList[$row['order_id']][] = $row;
        }

        foreach ($orderList as $order) {
            if ($order['source'] != 'matrix') continue;

            foreach ($status as $s) {
                $sdf = array(
                    'order_bn'               => $order['order_bn'],
                    'message_produce_status' => $s,
                    'remark'                 => '',
                    'order_objects'          => $orderObjectList[$order['order_id']],
                );
                
                kernel::single('erpapi_router_request')->set('shop',$order['shop_id'])->order_message_produce($sdf,true);
            }
        }
    }
}
